
public class Poem {

    private final char[] first ;
    private final char[] second ;
    private final char[] third ;
    private final char[] fourth ;

    public Poem( char[] first , char[] second , char[] third , char[] fourth ){
        this.first = new char[ first.length ];
        System.arraycopy( first , 0 , this.first , 0 , first.length);

        this.second = new char[ second.length ];
        System.arraycopy( second , 0 , this.second , 0 , second.length);

        this.third = new char[ third.length ];
        System.arraycopy( third , 0 , this.third , 0 , third.length);
        
        this.fourth = new char[ fourth.length ];
        System.arraycopy( fourth , 0 , this.fourth , 0 , fourth.length);
    }

    public char[] getFirst(){
        return this.first ;
    }

    /* 之所以将该方法私有，是因为只期望这个类内部使用 */
    private String traversal( char[] chars ) {
        String sentence = "" ;
        if( chars != null && chars.length > 0 ) {
            for ( int i = 0 ; i < chars.length ; i++ ) {
                // System.out.print( chars[ i ] );
                sentence += chars[ i ] ; // 近"串"者"串" : 一个 char 类型的值 与 字符串 执行 连接运算，则 char 类型的值会变成字符串
                // System.out.println( i < chars.length - 1 ? "  " : "\n" );
                sentence += ( i < chars.length - 1 ? "  " : "\n" );
            }
        }
        return sentence ;
    }

    @Override
    public String toString(){
        String p = "" ;
        p += traversal( first );
        p += traversal( second );
        p += traversal( third );
        p += traversal( fourth );
        return p ;
    }

    public static void main(String[] args) {

        char[] f = { '春' , '眠' , '不' , '觉' , '晓' } ;
        char[] s = { '春' , '眠' , '不' , '觉' , '晓' } ;
        char[] t = { '春' , '眠' , '不' , '觉' , '晓' } ;
        char[] o = { '春' , '眠' , '不' , '觉' , '晓' } ;

        Poem p = new Poem( f , s , t , o );
        System.out.println( p );

        char[] x = p.getFirst(); // 通过 getter 方法获取到了 可变对象 的 引用
        x[ 0 ] = '秋' ; // 通过 可变对象 的引用修改其中的数据

        System.out.println( p ); // 再次输出 p 时，内部数据发生变化

        System.out.println( "~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~" );

        final int[] array = new int[] { 1 , 3 , 5 };
        System.out.println( array );

        for ( int i = 0 ; i < array.length ; i++ ) {
            System.out.print( array[ i ] );
            System.out.println( i < array.length - 1 ? "  " : "\n" );
        }

        // 因为 变量 array 是 final 修饰符修饰的，因此 变量 array 的值是无法修改的
        // array = new int[] { 2 , 4 , 6 }; //【编译失败】 错误: 无法为最终变量array分配值

        array[ 0 ] = 2 ;
        array[ 1 ] = 4 ;
        array[ 2 ] = 6 ;

        for ( int i = 0 ; i < array.length ; i++ ) {
            System.out.print( array[ i ] );
            System.out.println( i < array.length - 1 ? "  " : "\n" );
        }
        
    }

}
